I am trying to run npm start on react and am coming up with the following error. I have tried re-installing npm and node.js. Error bind is not a function error continues to come up. What am I missing?
PS C:\Users\XXXXXXXXXX> npm run start
\XXXXXXXXX\node_modules\renderkid\node_modules\domutils\index.js:12
DomUtils[key] = ext[key].bind(DomUtils);
^
TypeError: ext[key].bind is not a function
at C:\XXXXXXXXXXXX\node_modules\renderkid\node_modules\domutils\index.js:12:28
at Array.forEach (<anonymous>)
at C:\XXXXXXXXXXXX\node_modules\renderkid\node_modules\domutils\index.js:11:19
at Array.forEach (<anonymous>)
at Object.<anonymous> (XXXXXXXXXXXX\node_modules\renderkid\node_modules\domutils\index.js:10:3)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
npm ERR! code 1
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c set PORT=3005 && react-scripts start
This is were the DomUtils is being called out in node_modules > Domutils > index.js
var DomUtils = module.exports;
[
require("./lib/stringify"),
require("./lib/traversal"),
require("./lib/manipulation"),
require("./lib/querying"),
require("./lib/legacy"),
require("./lib/helpers")
].forEach(function(ext){
Object.keys(ext).forEach(function(key){
DomUtils[key] = ext[key].bind(DomUtils);
});
});
I am using docker for first time to build a react application and host on ngnix, I have faced the same issue while building image for react application.
I used the following script to build the image and it helped, I have changed nodeJS version from node:7.10 to node:14.1-alpine.
Here is my Docker file
FROM node:14.1-alpine AS builder
WORKDIR /opt/web
COPY package.json package-lock.json ./
RUN npm install
ENV PATH="./node_modules/.bin:$PATH"
COPY . ./
RUN npm run build
FROM nginx:1.17.1-alpine
COPY --from=builder /opt/web/build /usr/share/nginx/html
Hope this is helpful for someone trying to build docker image for react application and host on ngnix.
I faced the same error. I did an npm install on my project git repository which modified by package-lock.json and consequently doing npm run start brought up this error.
In order to fix this, I restored my package-lock.json , did an npm ci instead and then doing npm run start worked.